fix: prevent spurious Lost status during intentional disconnect#162
Merged
fix: prevent spurious Lost status during intentional disconnect#162
Conversation
When Disconnect() is called, the transport fires StatusChanged(false) before Disconnect() sets Status = Disconnected, causing an unwanted Connected → Lost → Disconnected transition. Add an _isDisconnecting flag so OnTransportStatusChanged() skips the Lost state during intentional disconnects while still reporting it for unexpected drops. Closes #161 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Review Summary by QodoPrevent spurious Lost status during intentional disconnect
WalkthroughsDescription• Adds _isDisconnecting flag to distinguish intentional disconnects from unexpected transport drops • Prevents spurious Connected → Lost → Disconnected transition during Disconnect() calls • New test verifies no Lost status reported during intentional disconnect • Existing tests for unexpected transport losses remain unaffected Diagramflowchart LR
A["Disconnect called"] --> B["Set _isDisconnecting flag"]
B --> C["Transport fires StatusChanged"]
C --> D{"_isDisconnecting?"}
D -->|Yes| E["Skip Lost state"]
D -->|No| F["Report Lost status"]
E --> G["Set Disconnected status"]
F --> G
G --> H["Clear _isDisconnecting flag"]
File Changes1. src/Daqifi.Core/Device/DaqifiDevice.cs
|
Code Review by Qodo🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)
Great, no issues found!Qodo reviewed your code and found no material issues that require reviewⓘ The new review experience is currently in Beta. Learn more |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
_isDisconnectingflag toDaqifiDeviceto distinguish intentional disconnects from unexpected transport dropsConnected → Lost → Disconnectedtransition when callingDisconnect()— now goes straight toDisconnectedLoststatusCloses #161
Test plan
DaqifiDevice_Disconnect_ShouldNotReportLostStatusverifies noLoststatus during intentional disconnectDaqifiDevice_TransportConnectionLost_ShouldUpdateStatusstill passes for unexpected drops🤖 Generated with Claude Code